package com.hyt.it.ogt.ykcj.task.exam;

import com.hyt.it.ogt.ykcj.domain.exam.ExamInfo;
import com.hyt.it.ogt.ykcj.service.exam.IExamInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;

import java.util.List;

/**
 * description
 * 同步考生考试成绩到成绩分析表中
 *
 * @author yaojian
 * @createTime 2022/01/10
 */
//@Component
//@EnableScheduling
@Slf4j
public class ExamAnalysisDataTask {

    @Autowired
    private IExamInfoService examInfoService;


     //@Value("${task.getAnalysisDataTask.enabled}")
    private boolean enabled = false;

    @Scheduled(cron  = "${task.getAnalysisDataTask.cronExpress}")
    public void getAnalysisDataTask() throws Exception {
        if (enabled) {
            log.info("开始执行了定时任务。。。。");
            long startTime = System.currentTimeMillis();
            //获取所有的考试
            List<ExamInfo> examInfoList = examInfoService.selectExamInfoList(new ExamInfo());
            log.info(examInfoList.size() + "");
//            for (ExamInfo examInfo : examInfoList) {
//               examAnalysisTaskService.analysisExamById(examInfo.getId());
//            }
            long endTime = System.currentTimeMillis();
            log.info("定时任务调度时间。。" + (endTime - startTime));
        }
    }
}
